package crypto;

public class HexTest {

  public static void main(String[] args) {

    String s = "1";
    System.out.println(s.getBytes().length);

    printHexString(s.getBytes());

    byte[] bs = new byte[]{1, 2};
    printHexString(bs);
  }

  public static void printHexString(byte[] b) {
    for (int i = 0; i < b.length; i++) {
      String hex = Integer.toHexString(b[i] & 0xFF);
      if (hex.length() == 1) {
        hex = '0' + hex;
      }
      System.out.print(hex.toUpperCase());
    }
    System.out.println();
  }
}
